extends Card

var target = null  # 目标随从
var hasTrigger = false   # 是否触发

func init():
    att.cry = 1
    lv = 1
    type = TYPE.MAGIC
    camp = "m_hearthstone"
    name = "力量的代价"
    dec = "使一个友方随从获得+4/+4，该随从会在回合结束时死亡。"

func _use(card,cell):
    if card != null :
        card.att.atk += 4
        card.att.maxHp += 4
        target = card  # 绑定目标
        sys.scene.connect("onRoundEnd",self,"handleRoundEnd")
        
func useSelIf(card,cell):
    if card != null && card.type == TYPE.CREATURE && card.canSel && card.getHero() == getHero():
        return true
    return false

func handleRoundEnd():
    if !hasTrigger:
        target.cardDeath(target,false)
        hasTrigger = true